<template>
  <div id="HeatChart" style="display: flex;color: white">

  </div>
</template>

<script>
import * as echarts from 'echarts';
export default {
  name: "HeatChart",
  mounted() {
    this.initCharts()
  },
  methods: {
    initCharts() {
      const chartDom = document.getElementById('china-right-top');
      const myChart6 = echarts.init(chartDom);
      let option;
      $.get(this.$BaseUrl+"/projectHeat/getall",function(resw) {
                    const datas=[]
                    console.log(resw)
                    resw.forEach((value,index)=>{
                          datas.push({value:value['heat'],name:value['project']})

                    })
                    console.log(datas)

      option= {
        tooltip: {
          trigger: 'item'
        },
        legend: {
          top: '1%',
          left: 'center',
          color : ['#1e90ff','#22bb22','#4b0082','#d2691e'],
          backgroundColor: '#040f3c',
          // textStyle:'white'
        },
        series: [
          {
            name: '热度',
            type: 'pie',
            radius: ['30%', '70%'],
            avoidLabelOverlap: false,
            itemStyle: {
              borderRadius: 10,
              borderColor: '#040f3c',
              backgroundColor:'#040f3c',
              borderWidth: 2

            },
            label: {
              show: false,
              position: 'center'
            },
            emphasis: {
              label: {
                show: true,
                fontSize: '30',
                fontWeight: 'bold'
              }
            },
            labelLine: {
              show: false
            },
            data:datas
          }
        ]
      };

      option && myChart6.setOption(option);
      })
      window.addEventListener("resize",()=>{
        myChart6.resize();
      });
    }
  }
}
</script>

<style scoped>
#pie{
  position: absolute;
  width: 50%;
  height: 70%;
}
</style>
